import React, { Component } from 'react';
import './score.css';
import hz0 from './img/item_type_icon_1000.png';
import hz1 from './img/item_type_icon_1001.png';
import hz2 from './img/item_type_icon_1002.png';
import hz3 from './img/item_type_icon_1003.png';
import hz4 from './img/item_type_icon_1004.png';
import hz5 from './img/item_type_icon_1005.png';

class Score extends Component {


    getBadege(scroe){

        if(scroe === 0){
            return hz0;
        }

        if(scroe === 100){
            return hz5;
        }

        if(scroe >0 && scroe <=20){
            return hz1;
        }

        if(scroe > 20 && scroe <= 40){
            return hz2;
        }

        if(scroe > 40 && scroe <= 60){
            return hz3;
        }


        if(scroe > 60 && scroe < 100){
            return hz4;
        }

    }


    render() {

        let data = this.props.data.data;


        return (
            <div className="exam-score">

                    <div className="submit-time">
                        交卷时间: {data.time}
                    </div>

                    <div className="gap"></div>

                    <div className="socre-badge-box">
                        <img  style={{width:125, height:125}} src={this.getBadege(data.accuracy)}  alt='徽章' />
                    </div>
                    
                    <div className="score-number">
                        正确率:{data.accuracy}%
                    </div>

                    <div className="socre-detail-box">
                        <div className='left-box'>
                            <div>总题数:{data.count}</div>
                            <div>正确数:{data.true}</div>
                        </div>


                        <div className='right-box'>
                            <div>错误数:{data.error}</div>
                            <div>未答数:{data.empty}</div>
                        </div>
                    </div>

                </div>
        );
    }
}

export default Score;